<%@ page import="com.hc.commodity.dao.impl.CommodityDaoImpl" %>
<%@ page import="com.hc.commodity.pojo.Commodity" %>
<%@ page import="java.util.List" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/4/6
  Time: 16:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>商品</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
</head>
<body>
    <h1>欢迎使用胡氏商城</h1>
    <a href="ShoppingTrolley.jsp" class="btn btn-info">购物车</a>
    <%
        //调用dao层获取商品list集合
        CommodityDaoImpl commodityDao = new CommodityDaoImpl();
        List<Commodity> commodityList = commodityDao.findAll();
        pageContext.setAttribute("commodityList",commodityList);
    %>
    <div class="container">
        <ul class="nav nav-pills">
            <c:forEach items="${pageScope.commodityList}" var="commodity">
                <li role="presentation">
                    <img src="${commodity.cimage}" width="200px" height="200px">
                    <div>${commodity.ctitle}</div>
                    <div>${commodity.cprice}元</div>
                    <a href="addShoppingTrolley.jsp?cid=${commodity.cid}">购买</a>
                </li>
            </c:forEach>
        </ul>
    </div>


</body>
</html>
